using System;
using System.Collections.Generic;
using MvcMall.Core.Contacts.Repositories;
using MvcMall.Core.Contacts.Tasks;
using System.Linq;
using MvcMall.Core.Domains;

namespace MvcMall.Tasks
{
    public class StoreCategoryTask : IStoreCategoryTask
    {
        private readonly IStoreCategoryRepository _storeCategoryRepository;

        public StoreCategoryTask(IStoreCategoryRepository storeCategoryRepository)
        {
            _storeCategoryRepository = storeCategoryRepository;
        }

        public List<StoreCategory> GetFirstCats(int storeId)
        {
            return _storeCategoryRepository.QueryAll()
                .Where(c => c.ParentCat == null && c.Store.Id == storeId)
                .ToList();
        }
    }
}